/*
 * @Author: 王灿
 * @Date: 2019-10-27 15:07:03
 * @Description: file content
 */
import FastClick from 'fastclick'
const userAgent = navigator.userAgent.toLowerCase()

/**
 * @Date: 2019-10-27
 * @Author: 王灿
 * @Desc: 解决UIWebView不能禁止双击判断
 */
if (userAgent.indexOf('safari') > -1) {
    FastClick.attach(document.body)

    FastClick.prototype.focus = function(targetElement) {
        let length

        if (
            targetElement.setSelectionRange &&
            targetElement.type.indexOf('date') !== 0 &&
            targetElement.type !== 'time' &&
            targetElement.type !== 'month'
        ) {
            length = targetElement.value.length
            targetElement.focus()
            targetElement.setSelectionRange(length, length)
        } else {
            targetElement.focus()
        }
    }
}